/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2023-04-14
 * Time:22:02
 */

/**
 * JZ18 删除链表的节点
 */

public class deleteNode {
    public ListNode deleteNode (ListNode head, int val) {
        // write code here
        ListNode dummy = new ListNode(-1);
        dummy.next = head;
        ListNode slow = dummy;
        ListNode fast = dummy.next;
        while (fast != null){
            if (fast.val == val){
                slow.next = fast.next;
            }
            slow = slow.next;
            fast = fast.next;
        }
        return dummy.next;
    }
}
